<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/template_login.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core" >

    <ui:define name="title">
        <h:outputText value="#{bundle.CreateUserTitle}"></h:outputText>
    </ui:define>
    <ui:define name="body">
        <div class="visual">
            <div class="visual-block">
                <h2>BioDesk</h2>
            </div>
        </div>
        <p:fieldset legend="Sign Up" id="user_create" style="width:50%">
            <h:form id="sign_up">
                <p:messages id="msgs" autoUpdate="true" showDetail="true"/>
                <h:panelGrid columns="3" columnClasses="label,field">
                    <h:outputLabel value="#{bundle.CreateUserLabel_userLogin}" for="userLogin" />
                    <p:inputText id="userLogin" label="User Login"  value="#{userController.current.userLogin}"  required="true" requiredMessage="#{bundle.CreateUserRequiredMessage_userLogin}">
                        <f:ajax event="blur" listener="#{userController.validate()}"/>
                        <f:validateLength minimum="4"  maximum="45"   />
                    </p:inputText>
                    <p:message id="msg" for="userLogin"  display="icon" showDetail="true"/>

                    <h:outputLabel value="#{bundle.CreateUserLabel_userEmail}" for="userEmail" />
                    <p:inputText id="userEmail" label="Email" type="email" value="#{userController.current.userEmail}"  required="true" validatorMessage="Not a valid email" requiredMessage="#{bundle.CreateUserRequiredMessage_userEmail}"  >
                        <f:validateRegex  pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]"  />
                    </p:inputText>
                    <p:message for="userEmail" />
                    <h:outputLabel value="#{bundle.CreateUserLabel_userPass}" for="userPass" />
                    <p:password feedback="true"    id="userPass" value="#{userController.current.userPass}" title="#{bundle.CreateUserTitle_userPass}" required="true" requiredMessage="#{bundle.CreateUserRequiredMessage_userPass}"/>
                    <p:message for="userPass"  />
                </h:panelGrid>
                <br />
                <p:commandButton   action="#{userController.signup}" value="Sign" />
                <p:commandButton   action="cancel" value="Cancel" immediate="true"/>
            </h:form>
            <footer>
                <div class="foot">
                    <img src="../resources/css/DNA_1.png"/>
                </div>
            </footer>
        </p:fieldset>

    </ui:define>
</ui:composition>

